//
//  ViewController.m
//  NativeAddRN
//
//  Created by Shaoting Zhou on 2017/2/10.
//  Copyright © 2017年 9elephas. All rights reserved.
//

#import "ViewController.h"

#import "RNViewController.h"
#import "RNController2.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.navigationItem.title = @"我是原生页面";
    
    // 第一个入口和第二个入口分别进入两个RN模块（两份js代码--js、js2）
    
    // 第一个入口（进入RN），进入某个特定的RN模块
    UIButton *btn = [UIButton new];
    btn.backgroundColor = [UIColor lightGrayColor];
    [btn setTitle:@"到RN模块" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    btn.frame = CGRectMake(100, 300, 100, 40);
    [btn addTarget:self action:@selector(pushToRN) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    
    
    // 第二个入口（进入RN2），这个入口可以进入不同的RN模块，并共用一套导航系统
    // 设置RCTRootView的属性，可以根据属性判断进入哪一个RN子模块
    UIButton *btn2 = [UIButton new];
    btn2.backgroundColor = [UIColor lightGrayColor];
    [btn2 setTitle:@"到RN模块2" forState:UIControlStateNormal];
    [btn2 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    btn2.frame = CGRectMake(100, 400, 100, 40);
    [btn2 addTarget:self action:@selector(pushToRN2) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn2];
}

- (void)pushToRN
{
    RNViewController *rn = [RNViewController new];
    [self.navigationController pushViewController:rn animated:YES];
}

- (void)pushToRN2
{
    RNController2 *rn2 = [RNController2 new];
    [self.navigationController pushViewController:rn2 animated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
